推薦使用 Miniconda 作為套件與環境管理
Windows Server 版本的 IE 多了一層安全防護叫 IE Enhanced Security Configuration,停掉許多瀏覽器功能,以降低伺服器被滲透入侵的可能性。若要下載 Miniconda,須先將 IE Enhanced Security Configuration 關閉。
安裝 Miniconda 比較需要注意的是需要將 Add Miniconda 3 to PATH environment variable 打勾,這樣就能順利在 cmd/powershell 使用conda。
sudo apt update -y
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
rm Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
shioaji 支援 python 3.6 - 3.8,這邊選擇 3.8 做為虛擬環境
conda create -n sj-env python=3.8
啟用虛擬環境
conda activate sj-env
pip install shioaji
測試是否可以登入
import shioaji as sj
api = sj.Shioaji(simulation=True)
api.login('PAPIUSER02', '2222')
出現以下訊息代表成功囉
Response Code: 0 | Event Code: 0 | Info: host '218.32.76.102:80', hostname '218.32.76.102:80' IP 218.32.76.102:80 (host 1 of 1) (host connection attempt 1 of 1) (total connection attempt 1 of 1) | Event: Session up
[FutureAccount(person_id='PAPIUSER02', broker_id='F002000', account_id='9100295', signed=True, username='PAPIUSER02'), StockAccount(person_id='PAPIUSER02', broker_id='9A95', account_id='0504486', signed=True, username='PAPIUSER02')]